package com.ruoyi.web.wx.controller.pay;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.wx.pay.WxPayShare;
import com.ruoyi.system.service.wx.pay.IWxPayShareService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支出明细分享Controller
 * 
 * @author mic
 * @date 2023-08-31
 */
@RestController
@RequestMapping("/WxPayShare")
public class WxPayShareController extends BaseController
{
    @Autowired
    private IWxPayShareService wxPayShareService;

    /**
     * 查询支出明细分享列表
     */
    @PreAuthorize("@ss.hasPermi('WxPayShare:WxPayShare:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxPayShare wxPayShare)
    {
        startPage();
        List<WxPayShare> list = wxPayShareService.selectWxPayShareList(wxPayShare);
        return getDataTable(list);
    }

    /**
     * 导出支出明细分享列表
     */
    @PreAuthorize("@ss.hasPermi('WxPayShare:WxPayShare:export')")
    @Log(title = "支出明细分享", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxPayShare wxPayShare)
    {
        List<WxPayShare> list = wxPayShareService.selectWxPayShareList(wxPayShare);
        ExcelUtil<WxPayShare> util = new ExcelUtil<WxPayShare>(WxPayShare.class);
        util.exportExcel(response, list, "支出明细分享数据");
    }

    /**
     * 获取支出明细分享详细信息
     */
    @PreAuthorize("@ss.hasPermi('WxPayShare:WxPayShare:query')")
    @GetMapping(value = "/{shareId}")
    public AjaxResult getInfo(@PathVariable("shareId") String shareId)
    {
        return success(wxPayShareService.selectWxPayShareByShareId(shareId));
    }

    /**
     * 新增支出明细分享
     */
    @PreAuthorize("@ss.hasPermi('WxPayShare:WxPayShare:add')")
    @Log(title = "支出明细分享", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxPayShare wxPayShare)
    {
        return toAjax(wxPayShareService.insertWxPayShare(wxPayShare));
    }

    /**
     * 修改支出明细分享
     */
    @PreAuthorize("@ss.hasPermi('WxPayShare:WxPayShare:edit')")
    @Log(title = "支出明细分享", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxPayShare wxPayShare)
    {
        return toAjax(wxPayShareService.updateWxPayShare(wxPayShare));
    }

    /**
     * 删除支出明细分享
     */
    @PreAuthorize("@ss.hasPermi('WxPayShare:WxPayShare:remove')")
    @Log(title = "支出明细分享", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shareIds}")
    public AjaxResult remove(@PathVariable String[] shareIds)
    {
        return toAjax(wxPayShareService.deleteWxPayShareByShareIds(shareIds));
    }
}
